/**
 * 获得原型上的所有属性、
 * for in 拿不到所有属性，比如Symbol属性
 * 需要使用递归通过Reflect.ownKeys()，然后剔除内置属性
 */

class Grand {
  gName = 'Grand';
  gGetName() {
    return this.gName;
  }
}
Grand.prototype[Symbol.for('gAge')] = 'G-12';

class Parent extends Grand {
  pName = '123';
  pGetName() {
    return this.pName;
  }
}
Parent.prototype[Symbol.for('pAge')] = 'G-11';

class Child extends Parent {
  cName = '123';
  cGetName() {
    return this.cName;
  }
}

const child = new Child();

let result = [];

function logAllProperties(instance) {
  if (instance == null) return;
  let proto = instance.__proto__;
  while (proto) {
    result.push(...Reflect.ownKeys(proto));
    proto = proto.__proto__;
  }
}

logAllProperties(child);

console.log('result =', result);
